Last updated: 2019-06-22
Checks: 7 0
Knit directory: ~/Research-Local/RNAseq-Local/TCGA-Nigerian-RNAseq/
This reproducible R Markdown analysis was created with workflowr (version 1.4.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20190113) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Ignored: code/.DS_Store
Ignored: docs/.DS_Store
Ignored: docs/figure/.DS_Store
Ignored: plots/.DS_Store
Untracked files:
Untracked: analysis/quant/
Unstaged changes:
Deleted: analysis/NigerianTCGArawcountsDeSeq2-proteincoding.Rmd
Modified: analysis/about.Rmd
Modified: analysis/index.Rmd
Deleted: plots/FGA-Before-DE.jpeg
Deleted: plots/GALNT4-before-DE.jpeg
Deleted: plots/MT4-Before-DE.jpeg
Deleted: plots/NPIPA1 before DE.jpeg
Deleted: plots/STATH-Before-DE.jpeg
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.
#Translation from HTSeq raw counts -> Count Matrix I have 86 TCGA patients with whole-genome sequencing data and RNAseq data as well as 99 Nigerian patients with RNA-seq data. Raw counts were initially processed using HTSeq, so HTSeq data is being formatted for use with DESeq2 and limma-voom.
FOLDER <- "/Users/parajago/Research-Local/RNAseq-Local/Inputs/NigerianTCGA_quants-proteincoding"
sampleFiles <- grep("htseq.counts",list.files(FOLDER),value=TRUE)
#Differential gene expression setup based on race (b/w/other)
sampleConditionrace <- sampleFiles
countVar2=1
for (sample in sampleConditionrace){
if (stri_detect_fixed(sample,"LIB")==TRUE){
sampleConditionrace[countVar2] <- "Nigerian"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"black")==TRUE){
sampleConditionrace[countVar2] <- "TCGA_black"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"white")==TRUE){
sampleConditionrace[countVar2] <- "TCGA_white"
countVar2=countVar2+1
} else{
sampleConditionrace[countVar2] <- "TCGA_other"
countVar2=countVar2+1
}
}
#Condition based on PAM50 subtype
sampleConditionPAM50 <- sampleFiles
countVar2=1
for (sample in sampleConditionPAM50){
if (stri_detect_fixed(sample,"Her2")==TRUE){
sampleConditionPAM50[countVar2] <- "Her2"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"Basal")==TRUE){
sampleConditionPAM50[countVar2] <- "Basal"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"LumA")==TRUE){
sampleConditionPAM50[countVar2] <- "LumA"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"LumB")==TRUE){
sampleConditionPAM50[countVar2] <- "LumB"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"PAMNL")==TRUE){
sampleConditionPAM50[countVar2] <- "Normal"
countVar2=countVar2+1
} else{
sampleConditionPAM50[countVar2] <- "PAM_other"
countVar2=countVar2+1
}
}
#Condition based on batch (relevant to the Nigerian patients only; no difference in batch for the TCGA patients)
batchval <- sampleFiles
countVar2=1
for (sample in batchval){
if (stri_detect_fixed(sample,"batch1")==TRUE){
batchval[countVar2] <- "batch1"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"batch23")==TRUE){
batchval[countVar2] <- "batch23"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"batch4")==TRUE){
batchval[countVar2] <- "batch4"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"batch5")==TRUE){
batchval[countVar2] <- "batch5"
countVar2=countVar2+1
} else{
batchval[countVar2] <- "batchT"
countVar2=countVar2+1
}
}
table(sampleConditionrace, sampleConditionPAM50)
sampleConditionPAM50
sampleConditionrace Basal Her2 LumA LumB Normal PAM_other
Nigerian 32 26 16 18 7 0
TCGA_black 25 0 4 4 0 0
TCGA_other 0 0 0 0 0 14
TCGA_white 17 5 8 9 0 0
sampleTable2 <- data.frame(sampleName=gsub(".htseq.counts","",sampleFiles),
fileName=sampleFiles,
condition1=sampleConditionrace,
condition2=sampleConditionPAM50,
batch=batchval)
sampleTable2$sampleCondition <- paste(sampleTable2$condition1, sampleTable2$condition2, sep=".")
ddsHTSeqMF <- DESeqDataSetFromHTSeqCount(sampleTable=sampleTable2,
directory=FOLDER,
design=~sampleCondition)
ddsHTSeqMF <- ddsHTSeqMF[rowSums(counts(ddsHTSeqMF)) > 0, ] #Pre-filtering the dataset by removing the rows without any information about gene expression
#Quantile normalization Please refer to: https://parajago.github.io/TCGA-Nigerian-RNAseq/NigerianTCGArawcountsDeSeq2-pc2.html regarding comparison between the Nigerian and TCGA data sets and why quantile normalization under the limma-voom approach was chosen for primary differential expression analysis.
##Data visualization
countmatrix <- assay(ddsHTSeqMF) #Raw counts organized into matrix format from individual files
countmatrix2 <- log2(countmatrix + 1) #Basic transformation of the count data
plot(density(countmatrix2[,1]),lwd=3,ylim=c(0,.30), main="Density of counts with log2[count]+1 transformation ONLY")
for(i in 1:185){lines(density(countmatrix2[,i]),lwd=3)} #This demonstrates that there is a difference in distributions between the Nigerian and TCGA data with basic log transformation normalization
norm_countmatrix <- as.matrix(countmatrix2)
norm_countmatrix = normalize.quantiles(norm_countmatrix)
plot(density(norm_countmatrix[,1]),lwd=3,ylim=c(0,.3), main="Density of counts with quantile normalization")
for(i in 1:184){lines(density(norm_countmatrix[,i]),lwd=3)} #This demonstrates the effect of comparative quantile normalization
colnames (norm_countmatrix) <- colnames (countmatrix2)
rownames (norm_countmatrix) <- rownames (countmatrix2)
norm_countmatrix <- as.data.frame(norm_countmatrix)
countmatrixNigerian <- dplyr::select(norm_countmatrix, contains("LIB"))
plot(density(countmatrixNigerian[,1]),lwd=3,ylim=c(0,.3), main="Density of counts with quantile normalization - Nigerian")
for(i in 1:98){lines(density(countmatrixNigerian[,i]),lwd=3)} #This demonstrates the result of the normalized Nigerian counts separately
tcgacolnames <- colnames(countmatrix)
tcgacolnames <- setdiff(tcgacolnames, colnames(countmatrixNigerian))
countmatrixTCGA <- norm_countmatrix[ , tcgacolnames]
plot(density(countmatrixTCGA[,1]),lwd=3,ylim=c(0,.3), main="Density of counts with quantile normalization - TCGA")
for(i in 1:85){lines(density(countmatrixTCGA[,i]),lwd=3)} #This demonstrates the result of the normalized TCGA counts separately
norm_countmatrix <- as.data.frame(norm_countmatrix)
t_norm_countmatrix <- t(norm_countmatrix)
t_norm_countmatrix <- cbind (t_norm_countmatrix, sampleTable2) #This binds the characteristics of the original patients to the quantile normalized counts. CBinding was checked to make sure that patients were correctly aligned to characteristics.
quant.pca <- prcomp(t_norm_countmatrix[,1:19745])
autoplot(quant.pca, data=t_norm_countmatrix, colour='sampleCondition', main="PCA of quantile normalization results prior to DE analysis")
In the raw data with log transformation only, we are able to see that there are two peaks corresponding to the two datasets (Nigerian and TCGA). The quantile normalization demonstrates a PCA that has similar clustering and % explanations relative to VSD normalization. Only ~20% of the distribution of the data set is explained by the PCA1, 2 variables.
##Differential expression setup
annotation <- as.data.frame(row.names(countmatrix))
colnames(annotation) <- c("GeneID")
annotation$temp <- gsub("[.].+", "", annotation[,1])
annotation$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
annotation$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
annotation$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
annotation$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
annotation$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
annotation$temp <- NULL
design <- t_norm_countmatrix
design <- design %>% dplyr::select(sampleCondition)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA White - Basal
designNTW <- design
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="Nigerian.Basal", 0, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="TCGA_white.Basal", 1, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition==0 | designNTW$sampleCondition==1, designNTW$sampleCondition, NA)
designNTW <- designNTW %>% subset(is.na(sampleCondition)==FALSE)
designNTW$Nigerian.Basal <- ifelse (designNTW$sampleCondition==0, 1, 0)
designNTW$TCGA_white.Basal <- ifelse (designNTW$sampleCondition==1, 1, 0)
designNTW$sampleCondition <- NULL
mm <- model.matrix(~0+designNTW$Nigerian.Basal+designNTW$TCGA_white.Basal)
quantids <- rownames(designNTW)
rownames(mm) <- quantids
colnames(mm) <- c("Nigerian", "TCGA_white")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 14750 49
v=voom(d,designNTW,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(NigerianvsTCGAwhiteBasal = Nigerian.Basal-TCGA_white.Basal, levels=colnames(designNTW))
fit <- lmFit(v, designNTW)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
NigerianvsTCGAwhiteBasal
Down 2673
NotSig 10295
Up 1782
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential\n gene expression between basal breast cancers \nin Nigerian and \nTCGA white breast cancer patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between basal \nbreast cancers in Nigerian and \nTCGA white breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint <- df_limmaprint %>% arrange(log2FoldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(log2FoldChange)>0.58)
top_n(df_limmaprint, 10, log2FoldChange)
top_n(df_limmaprint, -10, log2FoldChange)
write.csv(df_limmaprint, file = "Nigerian-TCGAwhite-Basal-DE.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA Black - Basal
designNTW <- design
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="Nigerian.Basal", 0, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="TCGA_black.Basal", 1, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition==0 | designNTW$sampleCondition==1, designNTW$sampleCondition, NA)
designNTW <- designNTW %>% subset(is.na(sampleCondition)==FALSE)
designNTW$Nigerian.Basal <- ifelse (designNTW$sampleCondition==0, 1, 0)
designNTW$TCGA_black.Basal <- ifelse (designNTW$sampleCondition==1, 1, 0)
designNTW$sampleCondition <- NULL
mm <- model.matrix(~0+designNTW$Nigerian.Basal+designNTW$TCGA_black.Basal)
quantids <- rownames(designNTW)
rownames(mm) <- quantids
colnames(mm) <- c("Nigerian", "TCGA_black")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 16496 57
v=voom(d,designNTW,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(NigerianvsTCGAblackBasal = Nigerian.Basal-TCGA_black.Basal, levels=colnames(designNTW))
fit <- lmFit(v, designNTW)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
NigerianvsTCGAblackBasal
Down 2491
NotSig 11878
Up 2127
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential\n gene expression between basal breast cancers \nin Nigerian and \nTCGA black breast cancer patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between basal \nbreast cancers in Nigerian and \nTCGA black breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint <- df_limmaprint %>% arrange(log2FoldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(log2FoldChange)>0.58)
top_n(df_limmaprint, 10, log2FoldChange)
top_n(df_limmaprint, -10, log2FoldChange)
write.csv(df_limmaprint, file = "Nigerian-TCGAblack-Basal-DE.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA White - Her2
designNTW <- design
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="Nigerian.Her2", 0, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="TCGA_white.Her2", 1, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition==0 | designNTW$sampleCondition==1, designNTW$sampleCondition, NA)
designNTW <- designNTW %>% subset(is.na(sampleCondition)==FALSE)
designNTW$Nigerian.Her2 <- ifelse (designNTW$sampleCondition==0, 1, 0)
designNTW$TCGA_white.Her2 <- ifelse (designNTW$sampleCondition==1, 1, 0)
designNTW$sampleCondition <- NULL
mm <- model.matrix(~0+designNTW$Nigerian.Her2+designNTW$TCGA_white.Her2)
quantids <- rownames(designNTW)
rownames(mm) <- quantids
colnames(mm) <- c("Nigerian", "TCGA_white")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13871 31
v=voom(d,designNTW,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(NigerianvsTCGAwhiteHer2 = Nigerian.Her2-TCGA_white.Her2, levels=colnames(designNTW))
fit <- lmFit(v, designNTW)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
NigerianvsTCGAwhiteHer2
Down 680
NotSig 12888
Up 303
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential\n gene expression between Her2 breast cancers \nin Nigerian and \nTCGA white breast cancer patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between Her2 \nbreast cancers in Nigerian and \nTCGA white breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint <- df_limmaprint %>% arrange(log2FoldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(log2FoldChange)>0.58)
top_n(df_limmaprint, 10, log2FoldChange)
top_n(df_limmaprint, -10, log2FoldChange)
write.csv(df_limmaprint, file = "Nigerian-TCGAwhite-Her2-DE.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA White - LumA
designNTW <- design
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="Nigerian.LumA", 0, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="TCGA_white.LumA", 1, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition==0 | designNTW$sampleCondition==1, designNTW$sampleCondition, NA)
designNTW <- designNTW %>% subset(is.na(sampleCondition)==FALSE)
designNTW$Nigerian.LumA <- ifelse (designNTW$sampleCondition==0, 1, 0)
designNTW$TCGA_white.LumA <- ifelse (designNTW$sampleCondition==1, 1, 0)
designNTW$sampleCondition <- NULL
mm <- model.matrix(~0+designNTW$Nigerian.LumA+designNTW$TCGA_white.LumA)
quantids <- rownames(designNTW)
rownames(mm) <- quantids
colnames(mm) <- c("Nigerian", "TCGA_white")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13584 24
v=voom(d,designNTW,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(NigerianvsTCGAwhiteLumA= Nigerian.LumA-TCGA_white.LumA, levels=colnames(designNTW))
fit <- lmFit(v, designNTW)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
NigerianvsTCGAwhiteLumA
Down 998
NotSig 12007
Up 579
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential\n gene expression between LumA breast cancers \nin Nigerian and \nTCGA white breast cancer patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between LumA \nbreast cancers in Nigerian and \nTCGA white breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint <- df_limmaprint %>% arrange(log2FoldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(log2FoldChange)>0.58)
top_n(df_limmaprint, 10, log2FoldChange)
top_n(df_limmaprint, -10, log2FoldChange)
write.csv(df_limmaprint, file = "Nigerian-TCGAwhite-LumA-DE.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA Black - LumA
designNTW <- design
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="Nigerian.LumA", 0, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="TCGA_black.LumA", 1, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition==0 | designNTW$sampleCondition==1, designNTW$sampleCondition, NA)
designNTW <- designNTW %>% subset(is.na(sampleCondition)==FALSE)
designNTW$Nigerian.LumA <- ifelse (designNTW$sampleCondition==0, 1, 0)
designNTW$TCGA_black.LumA <- ifelse (designNTW$sampleCondition==1, 1, 0)
designNTW$sampleCondition <- NULL
mm <- model.matrix(~0+designNTW$Nigerian.LumA+designNTW$TCGA_black.LumA)
quantids <- rownames(designNTW)
rownames(mm) <- quantids
colnames(mm) <- c("Nigerian", "TCGA_black")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13461 20
v=voom(d,designNTW,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(NigerianvsTCGAblackLumA= Nigerian.LumA-TCGA_black.LumA, levels=colnames(designNTW))
fit <- lmFit(v, designNTW)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
NigerianvsTCGAblackLumA
Down 95
NotSig 13255
Up 111
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential\n gene expression between LumA breast cancers \nin Nigerian and \nTCGA black breast cancer patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between LumA \nbreast cancers in Nigerian and \nTCGA black breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint <- df_limmaprint %>% arrange(log2FoldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(log2FoldChange)>0.58)
top_n(df_limmaprint, 10, log2FoldChange)
top_n(df_limmaprint, -10, log2FoldChange)
write.csv(df_limmaprint, file = "Nigerian-TCGAblack-LumA-DE.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA White - LumB
designNTW <- design
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="Nigerian.LumB", 0, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="TCGA_white.LumB", 1, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition==0 | designNTW$sampleCondition==1, designNTW$sampleCondition, NA)
designNTW <- designNTW %>% subset(is.na(sampleCondition)==FALSE)
designNTW$Nigerian.LumB <- ifelse (designNTW$sampleCondition==0, 1, 0)
designNTW$TCGA_white.LumB <- ifelse (designNTW$sampleCondition==1, 1, 0)
designNTW$sampleCondition <- NULL
mm <- model.matrix(~0+designNTW$Nigerian.LumB+designNTW$TCGA_white.LumB)
quantids <- rownames(designNTW)
rownames(mm) <- quantids
colnames(mm) <- c("Nigerian", "TCGA_white")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13414 27
v=voom(d,designNTW,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(NigerianvsTCGAwhiteLumB= Nigerian.LumB-TCGA_white.LumB, levels=colnames(designNTW))
fit <- lmFit(v, designNTW)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
NigerianvsTCGAwhiteLumB
Down 769
NotSig 11973
Up 672
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential\n gene expression between LumB breast cancers \nin Nigerian and \nTCGA white breast cancer patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between LumB \nbreast cancers in Nigerian and \nTCGA white breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint <- df_limmaprint %>% arrange(log2FoldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(log2FoldChange)>0.58)
top_n(df_limmaprint, 10, log2FoldChange)
top_n(df_limmaprint, -10, log2FoldChange)
write.csv(df_limmaprint, file = "Nigerian-TCGAwhite-LumB-DE.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA Black - LumB
designNTW <- design
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="Nigerian.LumB", 0, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition=="TCGA_black.LumB", 1, as.character(designNTW$sampleCondition))
designNTW$sampleCondition <- ifelse (designNTW$sampleCondition==0 | designNTW$sampleCondition==1, designNTW$sampleCondition, NA)
designNTW <- designNTW %>% subset(is.na(sampleCondition)==FALSE)
designNTW$Nigerian.LumB <- ifelse (designNTW$sampleCondition==0, 1, 0)
designNTW$TCGA_black.LumB <- ifelse (designNTW$sampleCondition==1, 1, 0)
designNTW$sampleCondition <- NULL
mm <- model.matrix(~0+designNTW$Nigerian.LumB+designNTW$TCGA_black.LumB)
quantids <- rownames(designNTW)
rownames(mm) <- quantids
colnames(mm) <- c("Nigerian", "TCGA_black")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13373 22
v=voom(d,designNTW,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(NigerianvsTCGAblackLumB= Nigerian.LumB-TCGA_black.LumB, levels=colnames(designNTW))
fit <- lmFit(v, designNTW)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
NigerianvsTCGAblackLumB
Down 71
NotSig 13210
Up 92
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential\n gene expression between LumB breast cancers \nin Nigerian and \nTCGA black breast cancer patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between LumB \nbreast cancers in Nigerian and \nTCGA black breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint <- df_limmaprint %>% arrange(log2FoldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(log2FoldChange)>0.58)
top_n(df_limmaprint, 10, log2FoldChange)
top_n(df_limmaprint, -10, log2FoldChange)
write.csv(df_limmaprint, file = "Nigerian-TCGAblack-LumB-DE.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats4 grid stats graphics grDevices utils
[8] datasets methods base
other attached packages:
[1] Glimma_1.12.0 RColorBrewer_1.1-2
[3] preprocessCore_1.46.0 ashr_2.2-32
[5] ggfortify_0.4.7 calibrate_1.7.2
[7] MASS_7.3-51.4 sva_3.32.1
[9] mgcv_1.8-28 nlme_3.1-140
[11] EnsDb.Hsapiens.v75_2.99.0 ensembldb_2.8.0
[13] AnnotationFilter_1.8.0 GenomicFeatures_1.36.1
[15] hexbin_1.27.3 stringi_1.4.3
[17] dplyr_0.8.1 affy_1.62.0
[19] checkmate_1.9.3 pathview_1.24.0
[21] org.Hs.eg.db_3.8.2 AnnotationDbi_1.46.0
[23] clusterProfiler_3.12.0 pheatmap_1.0.12
[25] genefilter_1.66.0 vsn_3.52.0
[27] RUVSeq_1.18.0 EDASeq_2.18.0
[29] ShortRead_1.42.0 GenomicAlignments_1.20.0
[31] Rsamtools_2.0.0 Biostrings_2.52.0
[33] XVector_0.24.0 DESeq2_1.24.0
[35] SummarizedExperiment_1.14.0 DelayedArray_0.10.0
[37] BiocParallel_1.18.0 matrixStats_0.54.0
[39] Biobase_2.44.0 GenomicRanges_1.36.0
[41] GenomeInfoDb_1.20.0 IRanges_2.18.1
[43] S4Vectors_0.22.0 BiocGenerics_0.30.0
[45] edgeR_3.26.4 limma_3.40.2
[47] ggbiplot_0.55 scales_1.0.0
[49] plyr_1.8.4 ggplot2_3.1.1
[51] gplots_3.0.1.1
loaded via a namespace (and not attached):
[1] R.utils_2.8.0 tidyselect_0.2.5 RSQLite_2.1.1
[4] htmlwidgets_1.3 DESeq_1.36.0 munsell_0.5.0
[7] codetools_0.2-16 withr_2.1.2 colorspace_1.4-1
[10] GOSemSim_2.10.0 knitr_1.23 rstudioapi_0.10
[13] pscl_1.5.2 DOSE_3.10.1 labeling_0.3
[16] git2r_0.25.2 KEGGgraph_1.44.0 urltools_1.7.3
[19] GenomeInfoDbData_1.2.1 mixsqp_0.1-97 hwriter_1.3.2
[22] polyclip_1.10-0 bit64_0.9-7 farver_1.1.0
[25] rprojroot_1.3-2 xfun_0.7 doParallel_1.0.14
[28] R6_2.4.0 locfit_1.5-9.1 bitops_1.0-6
[31] fgsea_1.10.0 gridGraphics_0.4-1 assertthat_0.2.1
[34] ggraph_1.0.2 nnet_7.3-12 enrichplot_1.4.0
[37] gtable_0.3.0 workflowr_1.4.0 rlang_0.3.4
[40] splines_3.6.0 rtracklayer_1.44.0 lazyeval_0.2.2
[43] acepack_1.4.1 europepmc_0.3 BiocManager_1.30.4
[46] yaml_2.2.0 reshape2_1.4.3 backports_1.1.4
[49] qvalue_2.16.0 Hmisc_4.2-0 tools_3.6.0
[52] ggplotify_0.0.3 affyio_1.54.0 ggridges_0.5.1
[55] Rcpp_1.0.1 base64enc_0.1-3 progress_1.2.2
[58] zlibbioc_1.30.0 purrr_0.3.2 RCurl_1.95-4.12
[61] prettyunits_1.0.2 rpart_4.1-15 viridis_0.5.1
[64] cowplot_0.9.4 ggrepel_0.8.1 cluster_2.0.9
[67] fs_1.3.1 magrittr_1.5 data.table_1.12.2
[70] DO.db_2.9 triebeard_0.3.0 truncnorm_1.0-8
[73] SQUAREM_2017.10-1 ProtGenerics_1.16.0 aroma.light_3.14.0
[76] hms_0.4.2 evaluate_0.14 xtable_1.8-4
[79] XML_3.98-1.20 gridExtra_2.3 compiler_3.6.0
[82] biomaRt_2.40.0 tibble_2.1.3 KernSmooth_2.23-15
[85] crayon_1.3.4 R.oo_1.22.0 htmltools_0.3.6
[88] Formula_1.2-3 tidyr_0.8.3 geneplotter_1.62.0
[91] DBI_1.0.0 tweenr_1.0.1 Matrix_1.2-17
[94] R.methodsS3_1.7.1 gdata_2.18.0 igraph_1.2.4.1
[97] pkgconfig_2.0.2 rvcheck_0.1.3 foreign_0.8-71
[100] foreach_1.4.4 xml2_1.2.0 annotate_1.62.0
[103] stringr_1.4.0 digest_0.6.19 graph_1.62.0
[106] rmarkdown_1.13 fastmatch_1.1-0 htmlTable_1.13.1
[109] curl_3.3 gtools_3.8.1 jsonlite_1.6
[112] viridisLite_0.3.0 pillar_1.4.1 lattice_0.20-38
[115] KEGGREST_1.24.0 httr_1.4.0 survival_2.44-1.1
[118] GO.db_3.8.2 glue_1.3.1 UpSetR_1.4.0
[121] iterators_1.0.10 png_0.1-7 bit_1.1-14
[124] Rgraphviz_2.28.0 ggforce_0.2.2 blob_1.1.1
[127] latticeExtra_0.6-28 caTools_1.17.1.2 memoise_1.1.0